#include <bits/stdc++.h>
using namespace std;

struct node{
    int a, v, d;
}a[100005];

int p[100005];

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int t;
    cin >> t;
    while (t--)
    {
        int n, m, l, v;
        cin >> n >> m >> l >> v;
        for (int i= 1; i <= n; i++)
            cin >> a[i].d >> a[i].v >> a[i].a;
        for (int i = 1; i <= m; i++)
            cin >> p[i];
        cout << n << " " << m;
    }
    return 0;
}